---
category: Misc
created: '2020-05-02'
title: Run Promises in sequence
updated: '2021-10-13'
---

**JavaScript version**

```js run.js
// `promises` is an array of `Promise`
const run = (promises) => promises.reduce((p, c) => p.then((rp) => c.then((rc) => [...rp, rc])), Promise.resolve([]));
```

**TypeScript version**

```ts run.ts
const run = (promises: Promise<any>[]): Promise<any> =>
    promises.reduce((p, c) => p.then((rp) => c.then((rc) => [...rp, rc])), Promise.resolve([]));
```

**Examples**

```js examples.js
run(promises).then((results) => {
    // `results` is an array of promise results in the same order
});
```
